
Hanspeter Moessenboeck
ETH Zurich, Institute for Computer Systems
ETH-Zentrum, CH-8092 Zurich
E-Mail: moessenboeck@inf.ethz.ch
Oberon0 is a case study that demonstrates the design and implementation of an object-oriented window system with a text and a graphics editor. It is fully described in the book:
        H.Moessenboeck: Object-Oriented Programming in Oberon-2. Springer-Verlag, 1993.
The functionality of Oberon0 was derived from Oberon. However, Oberon0 is more basic because the emphasis is on learning object-oriented concepts rather than on utmost efficiency. All details that would have inflated the code without contributing to the object-oriented idea were omitted. The intention was to provide the source code of a small but realistic system and to allow studying it in all details, playing with it, and extending it.
        Oberon0 is written inOberon-2 a minor extension of the Oberon language that adds type-bound procedures (methods). You can thus only run it on Oberon systems that support Oberon-2 (i.e., on Sun SPARCStation, DECstation and IBM RS/6000 but currently not on IBM-PC or Macintosh).
To run Oberon0 you have first to compile its modules in the following order:
       OS.Mod  Interface to the Oberon system
        Viewers0.Mod    Viewer system with abstract frames
        AsciiTexts.Mod  Simple ASCII texts
        Texts0.Mod      Texts with fonts and elements that flow with the text
        TextFrames0.Mod Frames for showing a text on the screen
        IO.Mod  Basic input/output routines
        Oberon0.Mod     Handling user input (keyboard input and mouse clicks)
        Edit0.Mod       Main module of the text editor
        FoldElems0.Mod  Fold elements (see below)
        Shapes0.Mod     Abstract figures for the graphics editor
        GraphicFrames0.Mod      Frames to display figures on the screen
        Rectangles0.Mod Rectangles as concrete figures of the graphics editor
        Draw0.Mod       Main module of the graphics editor
        GraphicElems0.Mod       Graphic elements: Pictures that can be inserted in a text

The system is started with the command
        Oberon0.Loop
and can be terminated at any time by pressing the Escape key. Before you start Oberon0, close all viewers in the user track because Oberon0 will overwrite them with its own viewers. For a short look at the functionality of Oberon0 do the following:
- Invoke Oberon0.Loop. A viewer with the name LOG is opened.
- Enter the command Edit0.Open NewDocument.Text into the LOG viewer and execute it with the middle mouse button. A viewer with the name NewDocument.Text is opened. Now you can type characters, delete them with the DEL key, select, delete and copy them much like in the Oberon system. The edited text can be stored with the menu command Edit0.Store. Scrolling is also like in the Oberon system. Note that you cannot open Oberon text files with Edit0 because this editor uses a simpler text file format.
- Enter the command GraphicElems0.Insert into the LOG viewer. Place the caret in the text of your document and execute the command. A black box is inserted at the caret position. This is a graphics element. Click on it with the middle mouse button. A graphics viewer is opened. Enter the command Rectangles0.Set in the LOG viewer and execute it. Now you can use the left mouse button to draw rectangles in the graphics viewer. The drawing can be copied to the graphics element in the text by executing the command GraphicElems0.Update from the menu of the graphics viewer.
- Enter the command FoldElems0.Insert in the LOG viewer. Select a piece of text in your document and execute the command. The selected text is surrounded by small triangles. Click on the first triangle. The text is collapsed and two filled triangles are shown. Enter text between them, then click on the first triangle again. The collapsed text is shown again and the newly entered text is hidden. By repeatedly clicking on the first triangle you can toggle between the two texts. Folding a text is a very useful structuring mechanism in documents and even in source code of programs.
For a more detailed description of the Oberon0 commands please refer to the above-mentioned book. This book also helps you in understanding the implementation of Oberon0.

